{  26 February 2011. Individual Olympiad. Problem set: http://neerc.ifmo.ru/school/io/archive/20110226/problems-20110226-individual.pdf
	Problem A
	Points: 100
}
var i,n,j,x,y:longint; a:array[1..1001] of string;
begin
reset(input,'files.in');
rewrite(output,'files.out');
readln(n);
for i:=1 to n do readln(a[i]);
readln(n);
for i:=1 to n do begin
  readln(x,y);
  for j:=x to y do writeln(a[j]);
end;
end.
